import { defHttp } from '@/utils/http/axios';

enum Api {
  GetlistAPI = '/mv/config/page',
  dataDeleteAPI = '/mv/config/delete',
  AddpageListAPI = '/mv/config/add',
  uploadAPI = '/mv/config/update',
}

//获取订单列表信息
export function getlistAPI(params) {
  params['current'] = params.page;
  params['size'] = params.pageSize;
  return defHttp
    .post(
      {
        url: Api.GetlistAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      const { records, total } = res.data;
      return {
        items: records, // 将数据列表赋值给 items
        total, // 直接使用 total
      };
    })
    .catch((err) => {
      console.log(err, '配置管理');
    });
}

export function dataDeleteAPI(params) {
  return defHttp
    .get(
      {
        url: Api.dataDeleteAPI + '?id=' + params.id,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '删除信息');
    });
}

//添加配置
export function AddpageListAPI(params) {
  return defHttp
    .post(
      {
        url: Api.AddpageListAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '添加用户');
    });
}

export function uploadAPI(params) {
  return defHttp
    .post(
      {
        url: Api.uploadAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '上传文件');
    });
}
